package com.lin.linchatgpt.openai.server.imple;

import com.lin.linchatgpt.entity.Message;
import com.lin.linchatgpt.entity.dto.MessageDTO;
import com.lin.linchatgpt.openai.server.HistoryHandlerMessageStrategy;
import com.lin.linchatgpt.service.MessageService;
import org.springframework.beans.BeanUtils;

import java.util.List;

/**
 * Copyright(C),2022年-2022,霖霖
 *
 * @author 霖霖
 * @version 1.0
 * @date 2023/6/22 21:08
 * @Description 修改消息的处理
 */
public class ModifyMessage implements HistoryHandlerMessageStrategy {

    private final MessageService messageService;

    public ModifyMessage(MessageService messageService) {
        this.messageService = messageService;
    }
    @Override
    public List<Message> historyMessageHandler(MessageDTO message) {
        Message messageDo = new Message();
        BeanUtils.copyProperties(message,messageDo);


        return messageService.modifyMessage(messageDo);
    }
}
